package com.oocl.ha.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.oocl.ha.client.vo.Complaint;

@Entity
@Table(name = "torder")
public class Order {

	public Order(Integer oid, Date orderTime, Double total, Integer taken, String dishs, Integer isScore,
			String comments, String address, User user, Merchant merchant) {
		super();
		this.oid = oid;
		this.orderTime = orderTime;
		this.total = total;
		this.taken = taken;
		this.dishs = dishs;
		this.isScore = isScore;
		this.comments = comments;
		this.address = address;
		this.user = user;
		this.merchant = merchant;
	}

	@Id
	@Column(name = "oid")
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Integer oid;
	@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone = "GMT+8:00")
	@Temporal(TemporalType.TIMESTAMP)
	private Date orderTime;

	@Column(name = "total")
	private Double total;

	@Column(name = "taken")
	private Integer taken;

	@Column(name = "dishs")
	private String dishs;

	@Column(name = "isScore")
	private Integer isScore;

	@Column(name = "comments")
	private String comments;

	@Column(name = "address")
	private String address;

	@JsonManagedReference
	@ManyToOne(targetEntity = User.class)
	@JoinColumn(name = "usid", referencedColumnName = "usid", nullable = false)
	private User user;
	@JsonManagedReference
	@ManyToOne(targetEntity = Merchant.class)
	@JoinColumn(name = "mid", referencedColumnName = "mid", nullable = false)
	private Merchant merchant;

	public Order() {
		super();
	}

	public Order(Date orderTime, Double total, Integer taken, String dishs, Integer isScore, String comments, User user,
			Merchant merchant) {
		super();
		this.orderTime = orderTime;
		this.total = total;
		this.taken = taken;
		this.dishs = dishs;
		this.isScore = isScore;
		this.comments = comments;
		this.user = user;
		this.merchant = merchant;
	}

	public Order(Integer oid, Date orderTime, Double total, Integer taken, String dishs, User user, Merchant merchant) {
		super();
		this.oid = oid;
		this.orderTime = orderTime;
		this.total = total;
		this.taken = taken;
		this.dishs = dishs;
		this.user = user;
		this.merchant = merchant;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public Integer getIsScore() {
		return isScore;
	}

	public void setIsScore(Integer isScore) {
		this.isScore = isScore;
	}

	public Integer getOid() {
		return oid;
	}

	public void setOid(Integer oid) {
		this.oid = oid;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public Double getTotal() {
		return total;
	}

	public void setTotal(Double total) {
		this.total = total;
	}

	public Integer getTaken() {
		return taken;
	}

	public void setTaken(Integer taken) {
		this.taken = taken;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public String getDishs() {
		return dishs;
	}

	public void setDishs(String dishs) {
		this.dishs = dishs;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

}
